<template>
  <div class="header wrap">
    <h1><img style="width:350px; border-radius: 20px; margin-top:4px;" src="@/assets/img/logo4.png" alt="" />
    </h1>
    <ul class="nav">
      <li :class="$route.path == '/home' ? 'active' : ''" @click="$router.push('/home')">
        首页
      </li>
      <li :class="$route.path == '/goods' ? 'active' : ''" @click="$router.push('/goods')">
        全部商品
      </li>
      <li :class="$route.path == '/user' ? 'active' : ''" @click="$router.push('/user')">
        个人中心
      </li>
      <li :class="$route.path == '/order' ? 'active' : ''" @click="$router.push('/order')">
        我的订单
      </li>
      <li :class="$route.path == '/free' ? 'active' : ''" @click="$router.push('/free')">
        专属福利
      </li>
    </ul>
    <div class="search">
      <input type="text" placeholder="请输入搜索内容" @keyup.enter="toSearch" v-model="userInputKeyword" />
      <span><img src="@/assets/img/search.png" alt="" /></span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      //用户输入的字
      userInputKeyword: "",
    };
  },
  methods: {
    //搜索跳转
    toSearch() {
      //跳转路由并传参数
      this.$router.push(`/goods?Keyword=${this.userInputKeyword}`);
      this.userInputKeyword = "";
      console.log(this.userInputKeyword);
    },
  },
};
</script>

<style lang="less" scoped>
@import "../assets/css/global.less";

.header {
  height: 118px;
  display: flex;
  justify-content: space-between;
  align-items: center;

  .nav {
    display: flex;
    width: 500px;
    justify-content: space-between;


    li {
      font-size: 16px;
      font-family: SourceHanSansSC, SourceHanSansSC-Medium;
      cursor: pointer;

      &.active {
        color: @base-color;
        font-weight: 700;
      }
    }
  }

  .search {
    display: flex;

    input {
      width: 214px;
      height: 38px;
      border: 1px solid #dedede;
      border-radius: 20px 0px 0px 20px;
      text-indent: 12px;
    }

    span {
      display: flex;
      width: 50px;
      height: 40px;
      background: #0C4FA6;
      border-radius: 0px 20px 20px 0px;
      justify-content: center;
      align-items: center;
      cursor: pointer;

      img {
        width: 20px;
        height: 20px;
      }
    }
  }
}
</style>